<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/school.css"/>
		<style>
			#add1{width: 80%;position: absolute;top:60%;bottom: 60px; left: 10%; background-color: #000;z-index: 2;opacity: 0.85;display: none;border-radius: 10px;}
			.add1_imgR{width: 22%;position: relative;margin-top:50px; margin-bottom:150px; float: right;margin-right: 7%;}
			.add1_imgL{width: 22%;position: relative;margin-top:50px; float: left;margin-left: 17%;}
			.del{position: relative;float: right;width: 10%;}
		</style>
	<script src="js/jquery-2.1.0.js"></script>
	<script>
		$(function(){



			var li = $(".tab_menu>li");
			$(".tab_menu>li").click(function(){
				var count=$(this).index();
				var liValue = li.eq(count).text();
				$.ajax("/fengwei/school/goods",{
					type:"get",
					data:{
						'goodCategory':liValue
					},
					success:function(data){
//                      在这里注册成功后跳转页面
						console.log(data);
						var dataObj = eval('('+data+')');
						setData(dataObj,count);
					},
					error:function(){
						alert(0);
					}
				});
				console.log(23);

			});

			$.ajax("/fengwei/school/goods",{
				type:"get",
				data:{
					'goodCategory':"土特产"
				},
				success:function(data){
//                      在这里注册成功后跳转页面
					console.log(data);
					var dataObj = eval('('+data+')');
					setData(dataObj,0);
				},
				error:function(){
					alert(0);
				}
			});

			function setData(dataObj,count){

				for(var i = 0;i<dataObj.length;i++){

					var goodsName = dataObj[i].goodsName;
					var goodsCity = dataObj[i].goodsCity;
					var goodsPrice = dataObj[i].goodsPrice;
					var goodsUnit = dataObj[i].goodsUnit;
					var arr = dataObj[i].fileUrl.split("\\");
					var src = arr[arr.length-2]+"/"+arr[arr.length-1];


					var one = document.getElementById("one");
					var two = document.getElementById("two");
					var three = document.getElementById("three");
					var four = document.getElementById("four");

					var newDiv = document.createElement("div");
					newDiv.setAttribute('class','school_goods');
					if(count == 0){
						one.appendChild(newDiv);
					} else if(count == 1){
						two.appendChild(newDiv);
					} else if(count == 2){
						three.appendChild(newDiv);
					} else if(count == 3){
						four.appendChild(newDiv);
					}
					newDiv.innerHTML = "<img class='school_goods_img' src='"+src+"'/>"+
							"<div class='school_goods_msg'>名称：<span class='goods_name'>'"+goodsName+"'</span><br/>" +
							"产地：<span class='goods_place'>'"+goodsCity+"'</span><br/>价格：<span class='goods_price'>'"+goodsPrice+"'<span class='goods_unit'>'"+goodsUnit+"'</span></span>";

					var totalHeight = 0;
					totalHeight += $('.school_goods').outerHeight(true);
					if(totalHeight>$(window).height()){
						console.log($(window).height());
						if(count == 0){
							$('#one').css('height',$(window).height()).css('overflow','scroll');
						} else if(count == 1){
							$('#two').css('height',$(window).height()).css('overflow','scroll');
						} else if(count == 2){
							$('#three').css('height',$(window).height()).css('overflow','scroll');
						} else if(count == 3){
							$('#four').css('height',$(window).height()).css('overflow','scroll');
						}

					}

					$(".school_goods").click(function(){
						var count=$(this).index();
						window.location.href = "details.html?goodsId="+dataObj[count].goodsId+"";
					})

				}
			}

		})
	</script>
</head>
<body>
	<div id="school_head">   <!-- 头部 -->
		<input type="search" name="" id="" value="" />
	</div>
	<!--end -->
	
<div class="school_box">
	<ul class="tab_menu">		<!-- 选项卡-->
		<li class="current">土特产</li>
		<li>水产</li>
		<li>水果</li>
		<li>小吃</li>
	</ul>
	<!-- menu end-->
	
	<div class="tab_box">    <!--货物 -->
		<div id="one">

		</div>
		
		<div class="hide" id="two">

		</div>
		
		<div class="hide" id="three">

		</div>
				
		<div class="hide" id="four">

		</div>

		</div>
		
</div>		

	<div id="footer">	<!--底部-->
		<ul>
			<li id="homeGo"><img src="img/HOME_no.png"/></li>
			<li id="schoolGo"><img src="img/school_choose.png"/></li>
			<li id="add"> <img src="img/add.png" id="more" onclick="showDivFun()"/></li>
			<li id="shoppingGo"><img src="img/SHOPPING.png"/></li>
			<li id="userGo" class="active"><img src="img/USER-head_no.png"/></li>
		</ul>
	</div>

	<div id="add1">
		<img class="del" src="img/X.png" onclick="closeDivFun()"/>
		<a href="releaseOrder.html"><img class="add1_imgL" src="img/fadan.png"/></a>
		<a href="acceptOrder.html"><img class="add1_imgR" src="img/jiedan.png"/></a>
	</div>
	<!-- 页面跳转--hbl-->
	<script>
		$(function(){
			function getUrl(){
				var str = location.href;//获取传过来的地址
				var arr = str.split("?");
				var str1 = arr[1];//获取？之后的内容
				userId = str1.split("=")[1];
				return userId;
			}
			var homeGo = $("#homeGo");
			var schoolGo = $("#schoolGo");
			var shoppingGo = $("#shoppingGo");
			var userGo = $("#userGo");
			var add = $("#add")
			homeGo.click(function(){
				window.location.href = "Home.html?userId="+getUrl()+"";
			})
			schoolGo.click(function(){
				window.location.href = "School.html?userId="+getUrl()+"";
			})
			shoppingGo.click(function(){
				window.location.href = "shoppingCart.html?userId="+getUrl()+"";
			})
			userGo.click(function(){
				window.location.href = "personCenter.html?userId="+getUrl()+"";
			})

		})
	</script>

<!--<script src="js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>-->
<script src="js/jquery.tabs.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
	$('.school_box').Tabs({
		event:'click'
	});
});
</script>
	<script>

		function showDivFun(){
			document.getElementById('add1').style.display='block';
		}
		//关闭事件
		function closeDivFun(){
			document.getElementById('add1').style.display='none';
		}
	</script>
</body>
</html>